<style>
    /*表头*/
    table thead {
        z-index: 2;
        position: sticky;
        position: -webkit-sticky;
        top: 0;
        background: #f4f4f4;
    }
    table thead tr th:first-child{
        position: sticky;
        top: 0;
        left: 0;
        background: #f4f4f4;
    }
    th:nth-child(2){
        position: sticky;
        left: 40px;
        background: #f4f4f4;
    }
    th:nth-child(3){
        position: sticky;
        left: 80px;
        background: #f4f4f4;
    }
    th:nth-child(4){
        position: sticky;
        left: 120px;
        background: #f4f4f4;
    }
    th:nth-child(5){
        position: sticky;
        left: 175px;
        background: #f4f4f4;
    }

    /*表格*/
    table tbody tr td:first-child {
        z-index: 1;
        position: sticky;
        position: -webkit-sticky;
        left: 0;
        background: #f4f4f4;
        box-shadow: 7px 0 5px -5px rgb(0 0 0 / 12%);
    }
    td:nth-child(2){
        position: sticky;
        left: 40px;
        background: #f4f4f4;
    }
    td:nth-child(3){
        position: sticky;
        left: 80px;
        background: #f4f4f4;
    }
    td:nth-child(4){
        position: sticky;
        left: 120px;
        background: #f4f4f4;
    }
    td:nth-child(5){
        position: sticky;
        left: 175px;
        background: #f4f4f4;
    }
</style>

<table class="table table-hover">
    <thead>
    <tr>
        @foreach($headers as $filed => $item)
        <th>{{ $item['title'] }}</th>
        @endforeach
    </tr>
    <tr style="color:#f56f9c">
        @foreach($headers as $filed => $item)
            @if($filed == 'plat')
                <td style="position: sticky; top: 0; left: 0; background: #f4f4f4;">TTL</td>
            @elseif($filed == 'comp_rate')
                <td>{{ $total['month0'] > 0 && $total['month_target'] > 0 ? numberFormat($total['month0'] / $total['month_target'],4) * 100 .'%' : 0 }}</td>
            @elseif($item['sumField'])
                <td>{{ array_key_exists($filed,$total) ? $total[$filed] : '' }}</td>
            @else
                <td></td>
            @endif
        @endforeach
    </tr>
    </thead>
    <tbody>
    @foreach($paginator as $row)
        <tr>
            <td>{{ $row->plat->title ?? '' }}</td>
            <td>{{ $row->area->area ?? '' }}</td>
            <td>{{ $row->country->country ?? '' }}</td>
            <td>{{ \App\Util\User::getUsernameById($row->seller_id) }}</td>
            <td>{{ \App\Models\Product\ProductClassify::$_season[$row->classify->season ?? 3] }}</td>
            <td>{{ $row->classify->title ?? '' }}</td>
            @for($i = \App\Models\SalesReport\MonthlyCv::V_NUM -1; $i >= 0; $i--)
                <td>{{ $row->{'month'.$i} }}</td>
            @endfor
            <td>{{ $row->month_target }}</td>
            <td>{{ $row->month0 > 0 && $row->month_target > 0 ? numberFormat($row->month0 / $row->month_target,4) * 100 .'%' : 0 }}</td>
        </tr>
    @endforeach
    </tbody>
</table>
